use core::ops::Deref;

use stm32f4::stm32f407::{gpioa, gpiob, gpioc, gpiod, gpioe, gpiof, gpiog, gpioh, gpioi, gpioj, gpiok,
    GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH, GPIOI, GPIOJ, GPIOK
};


pub struct PA;
pub struct PB;
pub struct PC;
pub struct PD;
pub struct PE;
pub struct PF;
pub struct PG;
pub struct PH;
pub struct PI;
pub struct PJ;
pub struct PK;

impl Deref for PA {
    type Target = gpioa::RegisterBlock;
    fn deref(&self) -> &Self::Target {
        unsafe { &*GPIOA::PTR }
    }
}

impl Deref for PB {
    type Target = gpiob::RegisterBlock;
    fn deref(&self) -> &Self::Target {
        unsafe { &*GPIOB::PTR }
    }
}

impl Deref for PC {
    type Target = gpioc::RegisterBlock;
    fn deref(&self) -> &Self::Target {
        unsafe { &*GPIOC::PTR }
    }
}

impl Deref for PD {
    type Target = gpiod::RegisterBlock;
    fn deref(&self) -> &Self::Target {
        unsafe { &*GPIOD::PTR }
    }
}

impl Deref for PE {
    type Target = gpioe::RegisterBlock;
    fn deref(&self) -> &Self::Target {
        unsafe { &*GPIOE::PTR }
    }
}

impl Deref for PF {
    type Target = gpiof::RegisterBlock;
    fn deref(&self) -> &Self::Target {
        unsafe { &*GPIOF::PTR }
    }
}

impl Deref for PG {
    type Target = gpiog::RegisterBlock;
    fn deref(&self) -> &Self::Target {
        unsafe { &*GPIOG::PTR }
    }
}

impl Deref for PH {
    type Target = gpioh::RegisterBlock;
    fn deref(&self) -> &Self::Target {
        unsafe { &*GPIOH::PTR }
    }
}

impl Deref for PI {
    type Target = gpioi::RegisterBlock;
    fn deref(&self) -> &Self::Target {
        unsafe { &*GPIOH::PTR }
    }
}

impl Deref for PJ {
    type Target = gpioj::RegisterBlock;
    fn deref(&self) -> &Self::Target {
        unsafe { &*GPIOJ::PTR }
    }
}

impl Deref for PK {
    type Target = gpiok::RegisterBlock;
    fn deref(&self) -> &Self::Target {
        unsafe { &*GPIOK::PTR }
    }
}
